In [1]:
import numpy as np
#import time
#from scipy.stats import chi2
from matplotlib import pyplot as plt
from __future__ import division
#from itertools import product
from spacetime.CA_Simulators.CAs import *
from spacetime.Local_Measures.Local_Complexity import *
from spacetime.Local_Measures.Spacetime_Information import *
%matplotlib inline

Pure light cone tests


In [2]:
np.random.seed(0)
lc_test = np.random.choice([0,1],(10,10))
print lc_test


[[0 1 1 0 1 1 1 1 1 1]
 [1 0 0 1 0 0 0 0 0 1]
 [0 1 1 0 0 1 1 1 1 0]
 [1 0 1 0 1 1 0 1 1 0]
 [0 1 0 1 1 1 1 1 0 1]
 [0 1 1 1 1 0 1 0 0 1]
 [1 0 1 0 1 0 0 0 0 0]
 [1 1 0 0 0 1 1 0 1 0]
 [0 1 0 1 1 1 1 1 1 0]
 [1 1 0 0 1 0 0 1 1 0]]

In [10]:
plcs = pure_PLCs(3, 1, 2)
plcs.scan_data(lc_test)
label = plcs.all_labels()[4][2]
config = plcs.all_configs()[4][2]
print label
print config
print plcs.map_to_label(config)
print plcs.map_to_config(label)
print plcs.get_config_str((4,2))
print plcs.get_label((4,2))


76
01001100
76
01001100
01001100
76

In [4]:
flcs = pure_FLCs(3, 1, 2)
flcs.scan_data(lc_test)
Flabel = flcs.all_labels()[4][2]
Fconfig = flcs.all_configs()[4][2]
print Flabel
print Fconfig
print flcs.map_to_label(Fconfig)
print flcs.map_to_config(Flabel)
print flcs.get_label((4,2))
print flcs.get_config_str((4,2))


245
11110101
245
11110101
245
11110101

Spacetime information tests


In [5]:
test_field = np.zeros((10,10), dtype = int)
fill = np.ones((2,10),dtype = int)
test_field = np.vstack((fill,test_field,fill))
time, space = np.shape(test_field)
test_field[2]+=2
test_field[11]+=2
print test_field


[[1 1 1 1 1 1 1 1 1 1]
 [1 1 1 1 1 1 1 1 1 1]
 [2 2 2 2 2 2 2 2 2 2]
 [0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0]
 [2 2 2 2 2 2 2 2 2 2]
 [1 1 1 1 1 1 1 1 1 1]
 [1 1 1 1 1 1 1 1 1 1]]

In [6]:
test = information_field(test_field,3,2,1)

In [7]:
print test.past()


[['11111111' '11111111' '11111111' '11111111' '11111111' '11111111'
  '11111111' '11111111' '11111111' '11111111']
 ['22211111' '22211111' '22211111' '22211111' '22211111' '22211111'
  '22211111' '22211111' '22211111' '22211111']
 ['00022222' '00022222' '00022222' '00022222' '00022222' '00022222'
  '00022222' '00022222' '00022222' '00022222']
 ['00000000' '00000000' '00000000' '00000000' '00000000' '00000000'
  '00000000' '00000000' '00000000' '00000000']
 ['00000000' '00000000' '00000000' '00000000' '00000000' '00000000'
  '00000000' '00000000' '00000000' '00000000']
 ['00000000' '00000000' '00000000' '00000000' '00000000' '00000000'
  '00000000' '00000000' '00000000' '00000000']
 ['00000000' '00000000' '00000000' '00000000' '00000000' '00000000'
  '00000000' '00000000' '00000000' '00000000']
 ['00000000' '00000000' '00000000' '00000000' '00000000' '00000000'
  '00000000' '00000000' '00000000' '00000000']
 ['00000000' '00000000' '00000000' '00000000' '00000000' '00000000'
  '00000000' '00000000' '00000000' '00000000']
 ['00000000' '00000000' '00000000' '00000000' '00000000' '00000000'
  '00000000' '00000000' '00000000' '00000000']
 ['22200000' '22200000' '22200000' '22200000' '22200000' '22200000'
  '22200000' '22200000' '22200000' '22200000']]

In [8]:
print test.present()


[[2 2 2 2 2 2 2 2 2 2]
 [0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0]
 [2 2 2 2 2 2 2 2 2 2]
 [1 1 1 1 1 1 1 1 1 1]]

In [9]:
print test.future()


[['000' '000' '000' '000' '000' '000' '000' '000' '000' '000']
 ['000' '000' '000' '000' '000' '000' '000' '000' '000' '000']
 ['000' '000' '000' '000' '000' '000' '000' '000' '000' '000']
 ['000' '000' '000' '000' '000' '000' '000' '000' '000' '000']
 ['000' '000' '000' '000' '000' '000' '000' '000' '000' '000']
 ['000' '000' '000' '000' '000' '000' '000' '000' '000' '000']
 ['000' '000' '000' '000' '000' '000' '000' '000' '000' '000']
 ['000' '000' '000' '000' '000' '000' '000' '000' '000' '000']
 ['222' '222' '222' '222' '222' '222' '222' '222' '222' '222']
 ['111' '111' '111' '111' '111' '111' '111' '111' '111' '111']
 ['111' '111' '111' '111' '111' '111' '111' '111' '111' '111']]

In [10]:
print test.h_mu()
print test.h_mu_slow()
print np.mean(test.h_field())


0.376519040916
0.376519040916
0.376519040916

In [11]:
test.h_field()


Out[11]:
array([[-0.        , -0.        , -0.        , -0.        , -0.        ,
        -0.        , -0.        , -0.        , -0.        , -0.        ],
       [-0.        , -0.        , -0.        , -0.        , -0.        ,
        -0.        , -0.        , -0.        , -0.        , -0.        ],
       [-0.        , -0.        , -0.        , -0.        , -0.        ,
        -0.        , -0.        , -0.        , -0.        , -0.        ],
       [ 0.22239242,  0.22239242,  0.22239242,  0.22239242,  0.22239242,
         0.22239242,  0.22239242,  0.22239242,  0.22239242,  0.22239242],
       [ 0.22239242,  0.22239242,  0.22239242,  0.22239242,  0.22239242,
         0.22239242,  0.22239242,  0.22239242,  0.22239242,  0.22239242],
       [ 0.22239242,  0.22239242,  0.22239242,  0.22239242,  0.22239242,
         0.22239242,  0.22239242,  0.22239242,  0.22239242,  0.22239242],
       [ 0.22239242,  0.22239242,  0.22239242,  0.22239242,  0.22239242,
         0.22239242,  0.22239242,  0.22239242,  0.22239242,  0.22239242],
       [ 0.22239242,  0.22239242,  0.22239242,  0.22239242,  0.22239242,
         0.22239242,  0.22239242,  0.22239242,  0.22239242,  0.22239242],
       [ 0.22239242,  0.22239242,  0.22239242,  0.22239242,  0.22239242,
         0.22239242,  0.22239242,  0.22239242,  0.22239242,  0.22239242],
       [ 2.80735492,  2.80735492,  2.80735492,  2.80735492,  2.80735492,
         2.80735492,  2.80735492,  2.80735492,  2.80735492,  2.80735492],
       [-0.        , -0.        , -0.        , -0.        , -0.        ,
        -0.        , -0.        , -0.        , -0.        , -0.        ]])

In [12]:
print test.b_mu()
print test.b_mu_slow()
print np.mean(test.b_field())


0.577137776872
0.577137776872
0.577137776872

In [13]:
test.b_field()


Out[13]:
array([[ 3.        ,  3.        ,  3.        ,  3.        ,  3.        ,
         3.        ,  3.        ,  3.        ,  3.        ,  3.        ],
       [ 0.19264508,  0.19264508,  0.19264508,  0.19264508,  0.19264508,
         0.19264508,  0.19264508,  0.19264508,  0.19264508,  0.19264508],
       [ 0.19264508,  0.19264508,  0.19264508,  0.19264508,  0.19264508,
         0.19264508,  0.19264508,  0.19264508,  0.19264508,  0.19264508],
       [ 0.19264508,  0.19264508,  0.19264508,  0.19264508,  0.19264508,
         0.19264508,  0.19264508,  0.19264508,  0.19264508,  0.19264508],
       [ 0.19264508,  0.19264508,  0.19264508,  0.19264508,  0.19264508,
         0.19264508,  0.19264508,  0.19264508,  0.19264508,  0.19264508],
       [ 0.19264508,  0.19264508,  0.19264508,  0.19264508,  0.19264508,
         0.19264508,  0.19264508,  0.19264508,  0.19264508,  0.19264508],
       [ 0.19264508,  0.19264508,  0.19264508,  0.19264508,  0.19264508,
         0.19264508,  0.19264508,  0.19264508,  0.19264508,  0.19264508],
       [ 0.19264508,  0.19264508,  0.19264508,  0.19264508,  0.19264508,
         0.19264508,  0.19264508,  0.19264508,  0.19264508,  0.19264508],
       [ 0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
         0.        ,  0.        ,  0.        ,  0.        ,  0.        ],
       [ 1.        ,  1.        ,  1.        ,  1.        ,  1.        ,
         1.        ,  1.        ,  1.        ,  1.        ,  1.        ],
       [ 1.        ,  1.        ,  1.        ,  1.        ,  1.        ,
         1.        ,  1.        ,  1.        ,  1.        ,  1.        ]])

In [14]:
print test.q_mu()
print test.q_mu_slow()
print np.mean(test.q_field())


0.142138437212
0.142138437212
0.142138437212

In [15]:
test.q_field()


Out[15]:
array([[-0.54056838, -0.54056838, -0.54056838, -0.54056838, -0.54056838,
        -0.54056838, -0.54056838, -0.54056838, -0.54056838, -0.54056838],
       [ 0.26678654,  0.26678654,  0.26678654,  0.26678654,  0.26678654,
         0.26678654,  0.26678654,  0.26678654,  0.26678654,  0.26678654],
       [ 0.26678654,  0.26678654,  0.26678654,  0.26678654,  0.26678654,
         0.26678654,  0.26678654,  0.26678654,  0.26678654,  0.26678654],
       [ 0.04439412,  0.04439412,  0.04439412,  0.04439412,  0.04439412,
         0.04439412,  0.04439412,  0.04439412,  0.04439412,  0.04439412],
       [ 0.04439412,  0.04439412,  0.04439412,  0.04439412,  0.04439412,
         0.04439412,  0.04439412,  0.04439412,  0.04439412,  0.04439412],
       [ 0.04439412,  0.04439412,  0.04439412,  0.04439412,  0.04439412,
         0.04439412,  0.04439412,  0.04439412,  0.04439412,  0.04439412],
       [ 0.04439412,  0.04439412,  0.04439412,  0.04439412,  0.04439412,
         0.04439412,  0.04439412,  0.04439412,  0.04439412,  0.04439412],
       [ 0.04439412,  0.04439412,  0.04439412,  0.04439412,  0.04439412,
         0.04439412,  0.04439412,  0.04439412,  0.04439412,  0.04439412],
       [ 0.2370392 ,  0.2370392 ,  0.2370392 ,  0.2370392 ,  0.2370392 ,
         0.2370392 ,  0.2370392 ,  0.2370392 ,  0.2370392 ,  0.2370392 ],
       [-1.3479233 , -1.3479233 , -1.3479233 , -1.3479233 , -1.3479233 ,
        -1.3479233 , -1.3479233 , -1.3479233 , -1.3479233 , -1.3479233 ],
       [ 2.45943162,  2.45943162,  2.45943162,  2.45943162,  2.45943162,
         2.45943162,  2.45943162,  2.45943162,  2.45943162,  2.45943162]])

In [16]:
print test.sigma_mu()
print test.sigma_mu_slow()
print np.mean(test.sigma_field())


0.222580092337
0.222580092337
0.222580092337

In [17]:
test.sigma_field()


Out[17]:
array([[ 1.        ,  1.        ,  1.        ,  1.        ,  1.        ,
         1.        ,  1.        ,  1.        ,  1.        ,  1.        ],
       [ 0.19264508,  0.19264508,  0.19264508,  0.19264508,  0.19264508,
         0.19264508,  0.19264508,  0.19264508,  0.19264508,  0.19264508],
       [ 0.19264508,  0.19264508,  0.19264508,  0.19264508,  0.19264508,
         0.19264508,  0.19264508,  0.19264508,  0.19264508,  0.19264508],
       [-0.07038933, -0.07038933, -0.07038933, -0.07038933, -0.07038933,
        -0.07038933, -0.07038933, -0.07038933, -0.07038933, -0.07038933],
       [-0.07038933, -0.07038933, -0.07038933, -0.07038933, -0.07038933,
        -0.07038933, -0.07038933, -0.07038933, -0.07038933, -0.07038933],
       [-0.07038933, -0.07038933, -0.07038933, -0.07038933, -0.07038933,
        -0.07038933, -0.07038933, -0.07038933, -0.07038933, -0.07038933],
       [-0.07038933, -0.07038933, -0.07038933, -0.07038933, -0.07038933,
        -0.07038933, -0.07038933, -0.07038933, -0.07038933, -0.07038933],
       [-0.07038933, -0.07038933, -0.07038933, -0.07038933, -0.07038933,
        -0.07038933, -0.07038933, -0.07038933, -0.07038933, -0.07038933],
       [ 0.4150375 ,  0.4150375 ,  0.4150375 ,  0.4150375 ,  0.4150375 ,
         0.4150375 ,  0.4150375 ,  0.4150375 ,  0.4150375 ,  0.4150375 ],
       [ 1.        ,  1.        ,  1.        ,  1.        ,  1.        ,
         1.        ,  1.        ,  1.        ,  1.        ,  1.        ],
       [ 0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
         0.        ,  0.        ,  0.        ,  0.        ,  0.        ]])

Excess entropy of test field


In [18]:
ee_test = local_excess_entropy(test_field, 0)

In [19]:
ee_test.estimate_states(2,1)

In [20]:
print ee_test.forward_state_field()


[[5 5 5 5 5 5 5 5 5 5]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [4 4 4 4 4 4 4 4 4 4]]

In [21]:
print ee_test.reverse_state_field()


[[3 3 3 3 3 3 3 3 3 3]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [4 4 4 4 4 4 4 4 4 4]]

In [22]:
print np.shape(ee_test.forward_state_field())
print np.shape(ee_test.reverse_state_field())


(10, 10)
(10, 10)

In [23]:
print ee_test.forward_state_field()


[[5 5 5 5 5 5 5 5 5 5]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [4 4 4 4 4 4 4 4 4 4]]

In [24]:
print ee_test.reverse_state_field()[::-1]


[[4 4 4 4 4 4 4 4 4 4]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [2 2 2 2 2 2 2 2 2 2]
 [3 3 3 3 3 3 3 3 3 3]]

In [25]:
for i in xrange(10):
    print ee_test.joint_state_field()[i]


[(5, 4), (5, 4), (5, 4), (5, 4), (5, 4), (5, 4), (5, 4), (5, 4), (5, 4), (5, 4)]
[(2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2)]
[(2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2)]
[(2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2)]
[(2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2)]
[(2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2)]
[(2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2)]
[(2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2)]
[(2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2)]
[(4, 3), (4, 3), (4, 3), (4, 3), (4, 3), (4, 3), (4, 3), (4, 3), (4, 3), (4, 3)]

In [26]:
dist_test = ee_test.joint_state_dist()
for item in dist_test.items():
    print item


((5, 4), 0.1)
((4, 3), 0.1)
((2, 2), 0.8)

In [27]:
print ee_test.excess_entropy()


0.921928094887

In [28]:
print np.mean(ee_test.excess_entropy_field())


0.921928094887

In [29]:
print ee_test.excess_entropy_field()


[[ 3.32192809  3.32192809  3.32192809  3.32192809  3.32192809  3.32192809
   3.32192809  3.32192809  3.32192809  3.32192809]
 [ 0.32192809  0.32192809  0.32192809  0.32192809  0.32192809  0.32192809
   0.32192809  0.32192809  0.32192809  0.32192809]
 [ 0.32192809  0.32192809  0.32192809  0.32192809  0.32192809  0.32192809
   0.32192809  0.32192809  0.32192809  0.32192809]
 [ 0.32192809  0.32192809  0.32192809  0.32192809  0.32192809  0.32192809
   0.32192809  0.32192809  0.32192809  0.32192809]
 [ 0.32192809  0.32192809  0.32192809  0.32192809  0.32192809  0.32192809
   0.32192809  0.32192809  0.32192809  0.32192809]
 [ 0.32192809  0.32192809  0.32192809  0.32192809  0.32192809  0.32192809
   0.32192809  0.32192809  0.32192809  0.32192809]
 [ 0.32192809  0.32192809  0.32192809  0.32192809  0.32192809  0.32192809
   0.32192809  0.32192809  0.32192809  0.32192809]
 [ 0.32192809  0.32192809  0.32192809  0.32192809  0.32192809  0.32192809
   0.32192809  0.32192809  0.32192809  0.32192809]
 [ 0.32192809  0.32192809  0.32192809  0.32192809  0.32192809  0.32192809
   0.32192809  0.32192809  0.32192809  0.32192809]
 [ 3.32192809  3.32192809  3.32192809  3.32192809  3.32192809  3.32192809
   3.32192809  3.32192809  3.32192809  3.32192809]]

In [30]:
print np.shape(ee_test.excess_entropy_field())


(10, 10)

In [ ]:


In [31]:
t = 100
start_a = domain_54(4*t, 'a')
start_b = domain_54(4*t, 'd')
start_c = domain_54(4*t, 'c')
start = np.hstack((start_a,start_b, start_c))
more_particles = ECA(54, start)
more_particles.evolve(12*t)

In [32]:
particle_states = epsilon_field(more_particles.get_spacetime())
past = 3
future = 3
c = 1
particle_states.estimate_states(past,future,c)
particle_states.filter_data()

In [33]:
info_54 = information_field(more_particles.get_spacetime(),3,3,1)

In [ ]:
ee_18 = local_excess_entropy(more_particles.get_spacetime(), 0)
ee_18.estimate_states(3,1)

In [ ]:
diagram(particle_states.complexity_field(),t_min = 190, t_max = 210, x_min=590, x_max=610, colorbar = True)

In [ ]:
diagram(ee_18.excess_entropy_field(),t_min = 184, t_max = 204, x_min=590, x_max=610, colorbar = True)

In [ ]:
diagram(info_54.sigma_field(),t_min = 186, t_max = 206, x_min=590, x_max=610, colorbar = True)

In [ ]:
diagram(info_54.q_field(),t_min = 186, t_max = 206, x_min=590, x_max=610, colorbar = True, colors = plt.cm.bone)

In [ ]:
diagram(info_54.b_field(),t_min = 186, t_max = 206, x_min=590, x_max=610, colorbar = True, colors=plt.cm.Blues)

In [ ]:


In [ ]:
print np.shape(more_particles.get_spacetime())

In [ ]:
print np.shape(particle_states.get_causal_field())

In [ ]:
print np.shape(info_54.q_field())

In [ ]:
print np.shape(info_54.b_field())

In [ ]:
print np.shape(info_54.sigma_field())

In [ ]:
print np.shape(ee_18.excess_entropy_field())

In [ ]:
print np.shape(particle_states.complexity_field())

In [ ]: